<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"

      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      >
    <h:body>

        <ui:composition template="/WEB-INF/templates/commonLayout.xhtml">

            <ui:define name="content">

                <h:form>
                    <p:dataTable emptyMessage="No users saved" paginator="true" rows="10"  
                 paginatorTemplate="{PreviousPageLink} {PageLinks} {NextPageLink} {RowsPerPageDropdown}"  
                 rowsPerPageTemplate="10,15,30" value="#{factoryBackingBean.userTasks}" var="item">
                         <f:facet name="header">  
            Your Tasks  
        </f:facet> 
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="ID"/>
                            </f:facet>
                            <h:outputText value="#{item.inputId}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Problem"/>
                            </f:facet>
                            <h:outputText value="#{item.problemId}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="State"/>
                            </f:facet>
                            <h:outputText value="#{item.done ? 'Done !' : 'In Progress...'}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value=""/>
                            </f:facet>
                            <p:commandButton id="downloadLink" value="Download" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)"   
                                             icon="ui-icon-arrowthichk-s" rendered="#{item.done}" >  
                                <p:fileDownload value="#{fileDownloadController.handleDownload(item)}"/>  
                            </p:commandButton> 
                        </p:column> 

                    </p:dataTable>
                </h:form>

                <!-- kvoli downloadu suboru:-->

                <p:dialog modal="true" widgetVar="statusDialog" header="Status" draggable="false" closable="false" resizable="false">  
                    <p:graphicImage value="/design/ajaxloadingbar.gif" />  
                </p:dialog>  

                <script type="text/javascript">  
                    function start() {  
                        statusDialog.show();  
                    }  
  
                    function stop() {  
                        statusDialog.hide();  
                    }  
                </script>  


            </ui:define>
        </ui:composition>

    </h:body>

</html>
